using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Serialization;

namespace CSF.Communications.Sdp.ServiceLogic.Exceptions
{
  public  class SDPSystemException : SDPException
    {
        #region Private Members

      private long errorCode;
      private string message;

      #endregion Properties

      #region Properties

      /// <summary>
      /// Property to retain error code
      /// </summary>
      public long ErrorCode
      {
         get
         {
            return errorCode;
         }
      }

      /// <summary>
      /// User friendly to be set- Overriding Message propertyof base Error 
      /// </summary>
      public override string Message
      {
         get
         {
            return message;
         }
      }

      #endregion 

      #region Constructors

      #region SDPSystemException
      /// <summary>
      ///   Default Constructor
      /// </summary>
      public SDPSystemException()
      {
         errorCode = (long)SDPSystemError.SDPSystemException;
			base.EventId = (int)SDPSystemEvent.SDPSystemException;
      }

      #endregion SDPSystemException

      #region SDPSystemException(string)
      /// <summary>
      /// Constructor with two parameter to convert general Exception to
      /// custom Exception UISystemException and set custom error message.
      /// </summary>
      /// <param name="description">Custom message that is to be set</param>
      public SDPSystemException(string description)
      {
         errorCode = (long)SDPSystemError.SDPSystemException;
         message = description;
			base.EventId = (int)SDPSystemEvent.SDPSystemException;
      }

      #endregion

      #region SDPSystemException(Exception)
      /// <summary>
      ///   Constructor with one parameter to convert general Exception to
      /// custom Exception UISystemException.
      /// </summary>
      /// <param name="sdpUISystemException">System Exception that is caught</param>
        public SDPSystemException(Exception sdpSystemException)
      {
         errorCode = (long)SDPSystemError.SDPSystemException;
         message = sdpSystemException.Message;
			base.EventId = (int)SDPSystemEvent.SDPSystemException;
        }

      #endregion SDPSystemException(Exception)


       #region SDPSystemException(long,string)
      /// <summary>
      /// Constructor with two parameter to convert general Exception to
      /// custom Exception SDPUIHEBusinessException and set custom error message.
      /// </summary>
      /// <param name="businessErrorCode">Custom error code that is to be set</param>
      /// <param name="errorDescription">Custom message that is to be set</param>
      public SDPSystemException(long businessErrorCode, string errorDescription)
      {
         errorCode = businessErrorCode;
         message = errorDescription + Environment.NewLine;

			string errorText = string.Empty;

            if (Enum.IsDefined(typeof(SDPSystemError), (SDPSystemError)errorCode))
         {
             message += ((SDPSystemError)errorCode).ToString();
             errorText = ((SDPSystemEvent)errorCode).ToString();
         }
         else
         {
             message += SDPSystemError.SDPSystemException.ToString();
             errorText = SDPSystemError.SDPSystemException.ToString();
         }
         SDPSystemEvent be = (SDPSystemEvent)Enum.Parse(typeof(SDPSystemEvent), errorText);
			base.EventId = Convert.ToInt32(be);

      }

      #endregion

        #region SDPSystemException(string,Exception)
        /// <summary>
      /// Constructor with two parameter to convert general Exception to
      /// custom Exception UISystemException and set custom error message.
      /// </summary>
      /// <param name="description">Custom message that is to be set</param>
      /// <param name="sdpUISystemException">System Exception caught</param>
      public SDPSystemException(string description, Exception sdpSystemException)
      {
         errorCode = (long)SDPSystemError.SDPSystemException;
         message = description + Environment.NewLine + sdpSystemException.Message;
			base.EventId = (int)SDPSystemEvent.SDPSystemException;
      }

      #endregion
      #region SDPSystemException(SerializationInfo,StreamingContext)
      /// <summary>
      /// Constructor with two parameter to convert general Exception to
      /// custom Exception UIDataException and set custom error message.
      /// </summary>
      /// <param name="SerializationInfo">SerializationInfo</param>
      /// <param name="StreamingContext">StreamingContext</param>
      // deserialization constructor
      public SDPSystemException(SerializationInfo info, StreamingContext context)
      {
      }

        #endregion
      #endregion

    }
}
